<?php
class CF_App_Controller_Response_ExtDirect extends CF_App_Controller_Response_Abstract
{
	/**
	 * 
	 * @var array
	 */
	protected $_body;
	
	/**
	 * @return void
	 */
	public function __construct()
	{
		parent::__construct();
		
		$postRaw = (file_get_contents("php://input"));
		$postRaw = json_decode($postRaw, true);
		
		$this->_body = array(
			'type'		=>	'rpc',
			'tid'		=>	$postRaw['tid'],
			'action'	=>	$postRaw['action'],
			'method'	=>	$postRaw['method'],
			'result'	=>	array()
		);
	}
	
	/**
	 * 
	 * @param array $result
	 * @return CF_App_Controller_Response_ExtDirect $this
	 */
	public function setBody($body)
	{
		$this->_body['result'] = $body;
		return $this;
	}
	
	/**
	 * @return string
	 */
	public function getBodyContent()
	{
		return json_encode($this->_body);
	}
}